
function changePage() {
	var currentPage = $("#pagediv").pagination('getCurrentPage') - 1;
	jQuery.ajax({
				type : "GET",
				url : ctx + "/resource/resources",
				data : "page=" + currentPage,
				dataType : "json",
				success : function(resources) {
					$("#resourcelist").empty();
					$.each(resources,function(i) {
										var codeStr = "<div class=\"media mediaborder\">"
												+ "<div class=\"media-left media-middle\">"
												+ "<a href=\"#\"> "
												+ "<img class=\"media-object img-responsive maxwidth\" src=\""
												+ resources[i].pic
												+ "\" alt=\""
												+ resources[i].resourceName
												+ "\" />"
												+ "</a>"
												+ "</div>"
												+ "<div class=\"media-body\">"
												+ "<h4 class=\"list-group-item-heading\">"
												+"<a href=\""+ctx+"/resource/"+resources[i].resourceId+" \" >"
												+ resources[i].resourceAbstract
												+ "</a></h4>"
												+ "<p class=\"list-group-item-text\">"
												+"<a href=\""+ctx+"/resource/"+resources[i].resourceId+" \" >"
												+ resources[i].resourceAbstract
												+ "</a></p>"
												+ "<p>"
												+ getLabel(resources[i].resourceType.resourceTypeId,resources[i].resourceType.resourceTypeName)
												+ " <span class=\"r blogAuthLabel\">"
												+ "创建时间:"
												+ getFormatDate(resources[i].createDatetime)
												+ ",浏览次数:"
												+ resources[i].downCount
												+ "</span></p></div></div>";
										$("#resourcelist").append(codeStr);
									});

				}
			});
}
function changePageAjax() {
	var currentPage = $("#pagediv").pagination('getCurrentPage') - 1;
	jQuery.ajax({
				type : "GET",
				url : ctx + "/resource/resources/type/"+$("#resourceType").val(),
				data : "page=" + currentPage,
				dataType : "json",
				success : function(resources) {
					$("#resourcelist").empty();
					$.each(resources,function(i) {
										var codeStr = "<div class=\"media mediaborder\">"
												+ "<div class=\"media-left media-middle\">"
												+ "<a href=\"#\"> "
												+ "<img class=\"media-object img-responsive maxwidth\" src=\""
												+ resources[i].pic
												+ "\" alt=\""
												+ resources[i].resourceName
												+ "\" />"
												+ "</a>"
												+ "</div>"
												+ "<div class=\"media-body\">"
												+ "<h4 class=\"list-group-item-heading\">"
												+"<a href=\""+ctx+"/resource/"+resources[i].resourceId+" \" >"
												+ resources[i].resourceAbstract
												+ "</a></h4>"
												+ "<p class=\"list-group-item-text\">"
												+"<a href=\""+ctx+"/resource/"+resources[i].resourceId+" \" >"
												+ resources[i].resourceAbstract
												+ "</a></p>"
												+ "<p>"
												+ getLabel(resources[i].resourceType.resourceTypeName)
												+ " <span class=\"r blogAuthLabel\">"
												+ "创建时间:"
												+ getFormatDate(resources[i].createDatetime)
												+ ",浏览次数:"
												+ resources[i].downCount
												+ "</span></p></div></div>";
										$("#resourcelist").append(codeStr);
									});

				}
			});
}
function topTen() {
	jQuery.ajax({
		type : "GET",
		url : ctx + "/resource/top/10/count",
		data : "",
		dataType : "json",
		success : function(resources) {
			$("#resourceTopTen").empty();
			$.each(resources,function(i) {
					var resourceStr = "<a href=\""+ctx+"/resource/"+resources[i].resourceId+" \" class=\"list-group-item \">"+resources[i].resourceName+"<span class=\"view-count\">"+resources[i].downCount+"</span></a>";
					$("#resourceTopTen").append(resourceStr);
			});
		}
	});
}
function topRelationTen(typeId) {
	jQuery.ajax({
		type : "GET",
		url : ctx + "/resource/resource/10/type/"+typeId,
		data : "",
		dataType : "json",
		success : function(resources) {
			$("#relationTopTen").empty();
			$.each(resources,function(i) {
					var resourceStr = "<a href=\""+ctx+"/resource/"+resources[i].resourceId+" \" class=\"list-group-item \">"+resources[i].resourceName+"<span class=\"view-count\">"+resources[i].downCount+"</span></a>";
					$("#relationTopTen").append(resourceStr);
			});
		}
	});
}

function resourceType(){
	jQuery.ajax({
		type : "GET",
		url : ctx + "/resource/resourceType",
		data : "",
		dataType : "json",
		success : function(resourceTypes) {
			$("#resourceTypes").empty();
			$.each(resourceTypes,function(i) {
					var resourceStr = "<a href=\""+ctx+"/resource/fortype/"+resourceTypes[i].resourceTypeId+" \" class=\"hot-label \"  target=\"_self\"  >"+resourceTypes[i].resourceTypeName+"</a>";
					$("#resourceTypes").append(resourceStr);
			});
		}
	});
}


